package com.bank.service;

import java.math.BigInteger;
import java.util.Random;

import javax.annotation.Resource;
import org.apache.log4j.Logger;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.bank.common.Hash;

@Service("hashingService")
@Transactional
public class HashingService{
	protected static Logger logger = Logger.getLogger("service");
	
	@Resource(name="sessionFactory")
	private SessionFactory sessionFactory;
	
	public String createHashValue(String a){
		Hash hs = new Hash();
		String text = hs.textHasher(a);
		return text;
	
	}
	public boolean checkHashValue(String a,String b){
		Hash hs = new Hash();
		return hs.hashChecker(a, b);
	}
	String GenerateRandomNumber(int n) {
		final String[] intArray = {"1","2","3","4","5","6","7","8","9","0"};
		String number="";
		for(int i = 0;i<n;i++){
			int num = 0 + (int)(Math.random()*9);
			number = number.concat(intArray[num]);

		}
		return number;
    }
}